package com.lizx.persional.common.base;

import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableLogic;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;
import java.util.Date;

/**
 * 所有数据库实体必须继承此BaseEntity :
 * 1. id    自增主键, java data type : Long, mysql data type: bigint
 * 2. gmtCreate    创建时间, java data type : Date, mysql data type: datetime
 * 3. gmtModify    修改时间, java data type : Date, mysql data type: datetime
 * @author 江苏博沣
 */
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SuperEntity extends Model {

    /**
     * id
     */
    @TableId(value = "id", type = IdType.ID_WORKER_STR)
    private String id;

    /**
     * 创建时间
     */
    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    private Date gmtCreate;

    /**
     * 修改时间
     */
    @TableField(value = "gmt_modify", fill = FieldFill.INSERT, update = "now()")
    private Date gmtModify;

    /**
     * 是否逻辑删除
     */
    @TableLogic
    @TableField(value = "is_deleted", fill = FieldFill.INSERT)
    private Boolean deleted;

    /**
     * 是否启用
     */
    @TableField(value = "is_enable")
    private Boolean enable;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }
}
